package v1

import (
	"card/app/http/controllers/api"
	"card/app/logic"
	"card/app/requests"
	"card/pkg/response"
	"github.com/gin-gonic/gin"
)

type RegisterController struct {
	api.BaseApiController
}

func (ctrl *RegisterController) RegisterByEmail(c *gin.Context) {
	params := new(requests.RegisterByEmailRequest)
	if err := requests.Validate(c, params, requests.RegisterByEmail); err != nil {
		response.Error(c, err)
		return
	}
	memberLogic := logic.NewMember(c)
	err := memberLogic.RegisterByEmail(params)
	if err != nil {
		response.Error(c, err, "注册失败")
		return
	}
	response.Success(c, "注册成功")
}
